package com.czmh.etc.onlinepubsys.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.czmh.etc.common.core.annotation.ApiVersion;
import com.czmh.etc.onlinepubsys.feign.newrun.entity.yunnan.EtcYnApplyInfoVO;
import com.czmh.etc.onlinepubsys.feign.newrun.entity.yunnan.EtcYnShippingInfo;
import com.czmh.etc.onlinepubsys.json.JsonResult;
import com.czmh.etc.onlinepubsys.services.DianService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @ClassName：YuePubController
 * @Description：粤通卡发行控制器
 * @Author： sevenchen.
 * @Date：2019/10/14 10:33.
 * @Version：1.0.0
 */
@RestController
@RequestMapping("/{version}/api/dian/")
@Api(tags = "ETC发行接口【新】-云通卡")
public class DianController {
    @Autowired
    private DianService dianService;

    /**
     * 查询车辆是否已办理粤通卡
     * @param telePhoneNo 可为空! 手机号码
     * @param plateColor 不可为空! 车牌颜色: 0-蓝. 4-绿色.
     * @param plateNo 不可为空! 车牌号码
     * @return
     */
    @ApiVersion(1)
    @PostMapping(value = "loginByWx")
    @ApiOperation(value="微信登录", notes = "微信登录")
    public JsonResult loginByWx(String channelId, String code, String openId){
        return dianService.loginByWx(channelId, code, openId);
    }

    @ApiVersion(1)
    @GetMapping(value = "obuapply")
    @ApiOperation(value = "获取obu申办ID", notes = "获取obu申办ID")
    public JsonResult obuapply(){
        return dianService.obuapply();
    }

    @ApiVersion(1)
    @PostMapping(value = "saveYnApplyInfo")
    @ApiOperation(value = "保存申请信息", notes = "保存申请信息")
    public JsonResult saveYnApplyInfo(@RequestBody  EtcYnApplyInfoVO saveApplyReqDTO, HttpServletRequest request) throws Exception{
        return dianService.saveYnApplyInfo(saveApplyReqDTO);
    }
    
    @ApiVersion(1)
    @PostMapping(value = "banksign")
    @ApiOperation(value = "省对省银行签约", notes = "省对省银行签约")
    public JsonResult banksign(String applyId, String bankId, String miniRedirect, String userPhone) throws Exception{
        return dianService.banksign(applyId, bankId, miniRedirect, userPhone);
    }

    @ApiVersion(1)
    @PostMapping(value = "addShippingInfo")
    @ApiOperation(value = "添加收货信息", notes = "添加收货信息")
    public JsonResult addShippingInfo(@RequestBody EtcYnShippingInfo shippingInfo, HttpServletRequest request) throws Exception{
        return dianService.addShippingInfo(shippingInfo);
    }
    
    @ApiVersion(1)
    @GetMapping(value = "changeStatus/{applyId}")
    @ApiOperation(value = "银行卡绑定成功后修改状态", notes = "银行卡绑定成功后修改状态")
    public JsonResult changeStatus(@PathVariable String applyId) throws Exception{
        return dianService.changeStatus(applyId);
    }
}
